package spring.aop.demo.anno;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class PaluAop {
    @Before(value = "execution(* spring.aop.demo.anno.Palu.work(..)) && args(str)", argNames = "str")
    public void before(String str){
        System.out.println(str);
        System.out.println("我是之前执行的内容！");
    }

    @AfterReturning(value = "execution(* spring.aop.demo.anno.Palu.work(..))", argNames = "returnVal", returning = "returnVal")   //使用returning指定接收方法返回值的参数returnVal
    public void afterReturn(Object returnVal){
        System.out.println("返回值是："+returnVal);
    }
    /**
     * @Before("execution(* org.example.entity.Student.study())")
     * public void before(JoinPoint point){
     *     System.out.println("参数列表："+ Arrays.toString(point.getArgs()));
     *     System.out.println("我是之前执行的内容！");
     * }
     */

    /**
     * @Around("execution(* com.test.bean.Student.test(..))")
     * public Object around(ProceedingJoinPoint point) throws Throwable {
     *     System.out.println("方法执行之前！");
     *     Object val = point.proceed();
     *     System.out.println("方法执行之后！");
     *     return val;
     * }
     */
}
